/*
* Copyright (C) Microsoft. All rights reserved.  
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not 
* use this file except in compliance with the License.  You may obtain a copy 
* of the License at http://www.apache.org/licenses/LICENSE-2.0  
* 
* THIS CODE IS PROVIDED *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED 
* WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, 
* MERCHANTABLITY OR NON-INFRINGEMENT. 
*
* See the Apache License, Version 2.0 for specific language governing 
* permissions and limitations under the License.
*
*/

#include "pch.h"
#include "StudentInfoItem.h"

using namespace Windows::UI;
using namespace Windows::UI::Xaml;
using namespace Windows::UI::Xaml::Controls;
using namespace Windows::UI::Xaml::Media;

namespace ClassRoom
{

const unsigned int StudentInfoItem::_idWidth = 30;
const unsigned int StudentInfoItem::_nameWidth = 100;
const unsigned int StudentInfoItem::_mmWidth = 20;
const unsigned int StudentInfoItem::_ddWidth = 20;
const unsigned int StudentInfoItem::_yyWidth = 20;
const unsigned int StudentInfoItem::_hobbiesWidth = 100;
const unsigned int StudentInfoItem::_scoreWidth = 30;
const unsigned int StudentInfoItem::_height = 26;
const unsigned int StudentInfoItem::_margin = 5;

StudentInfoItem::StudentInfoItem(
    unsigned int id,
    Platform::String^ name,
    unsigned int mm,
    unsigned int dd,
    unsigned int yy,
    Platform::String^ hobbies,
    unsigned int score)
{
    Color color;
    color.A = 255;
    color.R = 255;
    color.G = 255;
    color.B = 0;
    Brush^ foreground = ref new Media::SolidColorBrush(color);

    TextBlock^ idBox = ref new TextBlock();
    idBox->Width = _idWidth;
    idBox->Height = _height;
    idBox->Margin = Thickness(_margin, _margin, _margin, _margin);
    idBox->Foreground = foreground;
    idBox->Text = id.ToString();

    TextBlock^ nameBox = ref new TextBlock();
    nameBox->Width = _nameWidth;
    nameBox->Height = _height;
    nameBox->Margin = Thickness(_margin, _margin, _margin, _margin);
    nameBox->Foreground = foreground;
    nameBox->Text = name;

    TextBlock^ mmBox = ref new TextBlock();
    mmBox->Width = _idWidth;
    mmBox->Height = _height;
    mmBox->Margin = Thickness(_margin, _margin, _margin, _margin);
    mmBox->Foreground = foreground;
    mmBox->Text = mm.ToString();

    TextBlock^ ddBox = ref new TextBlock();
    ddBox->Width = _idWidth;
    ddBox->Height = _height;
    ddBox->Margin = Thickness(_margin, _margin, _margin, _margin);
    ddBox->Foreground = foreground;
    ddBox->Text = dd.ToString();

    TextBlock^ yyBox = ref new TextBlock();
    yyBox->Width = _idWidth;
    yyBox->Height = _height;
    yyBox->Margin = Thickness(_margin, _margin, _margin, _margin);
    yyBox->Foreground = foreground;
    yyBox->Text = yy.ToString();

    TextBlock^ hobbiesBox = ref new TextBlock();
    hobbiesBox->Width = _hobbiesWidth;
    hobbiesBox->Height = _height;
    hobbiesBox->Margin = Thickness(_margin, _margin, _margin, _margin);
    hobbiesBox->Foreground = foreground;
    hobbiesBox->Text = hobbies;

    TextBlock^ scoreBox = ref new TextBlock();
    scoreBox->Width = _scoreWidth;
    scoreBox->Height = _height;
    scoreBox->Margin = Thickness(_margin, _margin, _margin, _margin);
    scoreBox->Foreground = foreground;
    scoreBox->Text = score.ToString();

    _item = ref new StackPanel();
    _item->Orientation = Orientation::Horizontal;
    _item->Children->Append(idBox);
    _item->Children->Append(nameBox);
    _item->Children->Append(mmBox);
    _item->Children->Append(ddBox);
    _item->Children->Append(yyBox);
    _item->Children->Append(hobbiesBox);
    _item->Children->Append(scoreBox);
}

Windows::UI::Xaml::UIElement^ StudentInfoItem::UIElement::get()
{
    return _item;
}

}